iconhelper: Respect -gtk-icon-style
authorBenjamin Otte <otte@redhat.com>
Sat, 10 May 2014 19:50:37 +0000 (21:50 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 14 May 2014 02:28:34 +0000 (04:28 +0200)
This allows styling of entry icons, treeview pixbufs and images. They
can now be forced to be symbolic or regular.

gtk/gtkiconhelper.c
gtk/gtkstylecontext.c
gtk/gtkstylecontextprivate.h

index ba7e27254193f3eb40a5995fda7058c4f76d02ec..b88cf02b116922f5b2b4c6c21465a1f966736c92 100644 (file)
 
 #include "config.h"
 
+#include "gtkiconhelperprivate.h"
+
 #include <math.h>
+
 #include "gtkiconhelperprivate.h"
+#include "gtkstylecontextprivate.h"
 
 struct _GtkIconHelperPrivate {
   GtkImageType storage_type;
@@ -254,7 +258,7 @@ check_invalidate_pixbuf (GtkIconHelper *self,
 }
 
 static GtkIconLookupFlags
-get_icon_lookup_flags (GtkIconHelper *self)
+get_icon_lookup_flags (GtkIconHelper *self, GtkStyleContext *context)
 {
   GtkIconLookupFlags flags = GTK_ICON_LOOKUP_USE_BUILTIN;
 
@@ -263,6 +267,8 @@ get_icon_lookup_flags (GtkIconHelper *self)
   if (self->priv->pixel_size != -1)
     flags |= GTK_ICON_LOOKUP_FORCE_SIZE;
 
+  flags |= _gtk_style_context_get_icon_lookup_flags (context);
+
   return flags;
 }
 
@@ -279,7 +285,7 @@ ensure_pixbuf_for_gicon (GtkIconHelper *self,
     return;
 
   icon_theme = gtk_icon_theme_get_default ();
-  flags = get_icon_lookup_flags (self);
+  flags = get_icon_lookup_flags (self, context);
 
   ensure_icon_size (self, context, &width, &height);
 
@@ -685,7 +691,7 @@ ensure_surface_for_gicon (GtkIconHelper   *self,
     return;
 
   icon_theme = gtk_icon_theme_get_default ();
-  flags = get_icon_lookup_flags (self);
+  flags = get_icon_lookup_flags (self, context);
 
   ensure_icon_size (self, context, &width, &height);
   scale = get_scale_factor (self, context);
index 0dd86c4900da56fa65d3ecaafcdd963d1e03e056..c9b1812a22ad18b0ea84cfa5e16177a824630895 100644 (file)
@@ -27,6 +27,7 @@
 #include "gtkcsscolorvalueprivate.h"
 #include "gtkcsscornervalueprivate.h"
 #include "gtkcssenginevalueprivate.h"
+#include "gtkcssenumvalueprivate.h"
 #include "gtkcssnumbervalueprivate.h"
 #include "gtkcssrgbavalueprivate.h"
 #include "gtkdebug.h"
@@ -4677,6 +4678,29 @@ _gtk_style_context_get_changes (GtkStyleContext *context)
   return context->priv->invalidating_context;
 }
 
+GtkIconLookupFlags
+_gtk_style_context_get_icon_lookup_flags (GtkStyleContext *context)
+{
+  GtkCssIconStyle icon_style;
+
+  g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0);
+
+  icon_style = _gtk_css_icon_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_STYLE));
+
+  switch (icon_style)
+    {
+    case GTK_CSS_ICON_STYLE_REGULAR:
+      return GTK_ICON_LOOKUP_FORCE_REGULAR;
+    case GTK_CSS_ICON_STYLE_SYMBOLIC:
+      return GTK_ICON_LOOKUP_FORCE_SYMBOLIC;
+    case GTK_CSS_ICON_STYLE_REQUESTED:
+      return 0;
+    default:
+      g_assert_not_reached ();
+      return 0;
+    }
+}
+
 static AtkAttributeSet *
 add_attribute (AtkAttributeSet  *attributes,
                AtkTextAttribute  attr,
index 0db71e99355849b35d710d32eb9e1f05dc92ba92..56b658c9faebb7690d70f8780d5a02dedfc4014a 100644 (file)
@@ -19,6 +19,8 @@
 #define __GTK_STYLE_CONTEXT_PRIVATE_H__
 
 #include "gtkstylecontext.h"
+
+#include "gtkicontheme.h"
 #include "gtkstyleproviderprivate.h"
 #include "gtkbitmaskprivate.h"
 #include "gtkcssvalueprivate.h"
@@ -54,6 +56,8 @@ void           _gtk_style_context_get_cursor_color           (GtkStyleContext
 
 void           _gtk_style_context_update_animating           (GtkStyleContext    *context);
 
+GtkIconLookupFlags _gtk_style_context_get_icon_lookup_flags  (GtkStyleContext    *context);
+
 G_END_DECLS
 
 #endif /* __GTK_STYLE_CONTEXT_PRIVATE_H__ */